<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    // sum是纯函数
    function sum(num1, num2) {
      return num1 + num2;
    }

    // add不是纯函数
    let foo = 10
    function add(num) {
      return foo + num;
    }

    add(5) //15
    foo = 20
    add(5) //25

    // add2是纯函数
    const bar = 10
    function add2(num) {
      return foo + num;
    }

    bar = 11;


    // add3不是纯函数
    const baz = {
      count: 10,
    }

    function add3(num) {
      return bar.count + num;
    }

    baz.count = 20


    // 是纯函数
    function pringInfo(info) {
      console.log(info.name, info.age);
    }

  </script>

</body>

</html>